package Search.a01BasicSearchdemo1;

import java.util.ArrayList;

public class Test3 {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 5};
        ArrayList<Integer> list = getIndex(arr, 5);
        for (int i = 0; i < list.size(); i++) {
            System.out.println(list.get(i));
        }
    }

    public static ArrayList<Integer> getIndex(int[] arr, int num) {
        ArrayList<Integer> list = new ArrayList<>();
        for (int i = 0; i < arr.length; i++) {
            if (num == arr[i]) {
                list.add(i);
            }
        }
        return list;
    }
}
